package com.tanhua.model.vo;

/**
 * Description:
 * User:$(USER)
 * Date:$(YEAR)-$(MONTH)-$(DAY)
 * Time:11:18
 */
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.UserLike;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class LikesVo implements Serializable {

    private String id; //用户id
    private String avatar; //头像
    private String nickname;//昵称
    private  String createDate; //创建时间

    public static LikesVo init(UserInfo userInfo, UserLike userLike){
        LikesVo vo = new LikesVo();
        vo.setId(userInfo.getId().toString());
        vo.setAvatar(userInfo.getAvatar());
        vo.setNickname(userInfo.getNickname());
        //计算时间
        DateTime date = DateUtil.date(userLike.getCreated());
        vo.setCreateDate(date.toString());
        return vo;
    }
}